$(document).ready(function () {
    var currPage = 1;
    var pageSize = 12;
    var pageCount = 0;
    studentsViewAjax();
    function studentsViewAjax() {
        $.ajax({
            url: 'student/page',
            type: 'post',
            data: {'currPage': currPage, 'pageSize': pageSize},
            dataType: 'json',
            success: function (dto) {
                $('.studentsViewUl > li:gt(0)').remove();//除了第一个li其余li删除
                $('.studentsViewUl > li:first').css('display', 'block');
                //console.log(dto);
                var $students = $(dto.tList);
                pageCount = dto.obj.pageCount;
                $students.each(function (i, student) {
                    //利用模板中存在一行静态数据 通过clone 克隆方法得到复制对象，将复制对象修改后追加到父元素中
                    var $newli = $('.studentsViewUl > li:first').clone();
                    $newli.find('ul li').eq(0).children('img').attr('src', student.imgsrc);
                    $newli.find('ul li').eq(1).children('span').text(student.sno);
                    $newli.find('ul li').eq(2).children('span').text(student.name);
                    $newli.find('ul li').eq(3).children('span').text(student.sex);
                    $('.studentsViewUl').append($newli)//在元素的内部的尾部追加
                });

                $('.studentsViewUl > li:first').css('display', 'none');
            }
        });
    }
    $('#changeBatch').click(function(){
        currPage = currPage< pageCount ?(currPage + 1):1;
        studentsViewAjax();
    });
});